<template>
	<view class="lee-wrap">
		<view class="p10">
			<u--input prefixIcon="search" placeholder="请输入门店名称" border="none" shape="circle"
				:customStyle="{background:'#f5f5f5',height:'60rpx',paddingLeft:'20rpx'}" v-model="newParams.store_name"
				@input="toSearch">
			</u--input>
		</view>
		<view class="container">
			<scroll-view scroll-y scroll-with-animation class="lee-tab-view menu-scroll-view bf5"
				:scroll-top="scrollTop" :scroll-into-view="itemId">
				<view v-for="(item,index) in typeList" :key="index" class="lee-tab-item"
					:class="[current == index ? 'lee-tab-item-active' : '']"
					:style="{color:current==index?'#000':'',fontWeight:current==index?'bold':''}"
					@click.stop="swichMenu(index)">
					<text class="u-line-1">{{item.label}}</text>
				</view>
			</scroll-view>
			<scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box"
				@scrolltolower="scrolltolower" :refresher-triggered="triggered">
				<view class="page-view">
					<view class="class-item" :id="'item' + index" v-for="(item , index) in storeList" :key="index">
						<view class="card c3 mb10 cshow">
							<view class="content">
								<view style="display: flex;justify-content: space-between;align-items: center;">
									<view class="content-text" style="font-size: 36rpx;font-weight: 700;">
										#{{ item.id }}
									</view>
									<view class="content-text" style="display: flex;align-items: center;">状态：
										<u-tag :type="statusList[item.status].type" size="mini" plain
											:text="statusList[item.status].name">
										</u-tag>
									</view>
								</view>
								<view class="content-text">门店名称：{{item.store_name}}</view>
								<view class="content-text">POI：{{item.dy_poi_id}}
								</view>
								<view class="content-text">
									OEM：{{item.oem_name}}</view>
								<view class="content-text">手机号：{{item.phone}}</view>
								<view class="content-text" v-if="menus.includes('store/store/cybl')">
									抽佣比例：{{ item.commission_ratio || 0 }}
								</view>
								<view class="content-text status">抖音匹配状态：
									<u-tag :type="store_match_statusList[item.store_match_status].type" size="mini"
										plain :text="store_match_statusList[item.store_match_status].name">
									</u-tag>
									<!-- <view class="box" style="margin-left: 40rpx;"
										@click="matchShowTap(item.store_match_error_text)"
										v-if="item.store_match_status != 2">
										<uni-icons type="chat" size="25" color="red"></uni-icons>
									</view> -->
								</view>
								<view class="content-text status">抖音同步状态：
									<u-tag :type="store_sync_statusList[item.store_sync_status].type" size="mini" plain
										:text="store_sync_statusList[item.store_sync_status].name">
									</u-tag>
								</view>
								<view class="content-text status" v-if="menus.includes('store/diandan')">接单状态(点单)：
									<u-tag :type="place_statusList[item.place_status].type" size="mini" plain
										:text="place_statusList[item.place_status].name">
									</u-tag>
								</view>
								<view class="content-text status" v-if="is_audi == 1">审核状态：
									<u-tag :type="audi_statusList[item.audi_status].type" size="mini" plain
										:text="audi_statusList[item.audi_status].name">
									</u-tag>
									<view class="box" style="margin-left: 40rpx;"
										@click="tipsShowTap(item.reject_reason)"
										v-if="is_audi == 1 && item.reject_reason">
										<uni-icons type="chat" size="25" color="red"></uni-icons>
									</view>
								</view>
								<view class="content-text status">当前配送平台：
									<u-tag :type="delivery_typeList[item.delivery_type].type" size="mini" plain
										:text="delivery_typeList[item.delivery_type].name">
									</u-tag>
								</view>
								<view class="content-text status">在线状态：
									<u-switch v-model="item.dy_status_name" :loading="loading" @change="switchBtn(item)"
										size="20" :activeColor="subColor"></u-switch>
								</view>
								<u-collapse :border="false">
									<u-collapse-item title="配送信息" icon="car">
										<view class="setting">
											<button type="primary" @click="peishong(item)" size="mini"
												v-if="menus.includes('store/store/edit_delivery_type')"
												class="storeBtn">配送设置</button>
											<button type="primary" @click="peishongRule(item,3)" size="mini"
												v-if="menus.includes('store/store/edit_delivery_type')"
												class="storeBtn">配送规则</button>
										</view>
									</u-collapse-item>
								</u-collapse>
								<view v-if="is_audi == 0 || item.audi_status == 1">
									<u-collapse :border="false"
										v-if="item.store_sync_status == 1 && menus.includes('store/store/jinjian')">
										<u-collapse-item title="收款账户" icon="rmb-circle">
											<view class="setting">
												<button type="primary" @click="jinjian(item)" size="mini"
													class="storeBtn">收款账户</button>
											</view>
										</u-collapse-item>
									</u-collapse>
								</view>
								<u-collapse :border="false">
									<u-collapse-item title="操作" name="Docs guide" icon="setting">
										<view class="setting">
											<button type="primary" @click="editStore(item,1)" size="mini"
												v-if="menus.includes('store/store/edit')" class="storeBtn">编辑</button>
											<view class="" style="display: flex;"
												v-if="is_audi == 0 || item.audi_status == 1 || item.is_chain == 1">
												<button type="primary" @click="chaPi(item)" size="mini"
													v-if="(item.store_match_status == 1 || item.store_match_status == 4) && menus.includes('store/store/store_query_task')"
													class="storeBtn">查询匹配</button>
												<button type="primary" @click="tong(item)" size="mini"
													v-if="(item.store_match_status == 2 && item.store_sync_status != 1 && menus.includes('store/store/dy_store_sync')) || adminInfo.oem_id==0 ||item.flag == 1 || item.flag == 2"
													class="storeBtn">同步抖音</button>
												<button type="primary" @click="qiAndJin(item, 0)" size="mini"
													v-if="item.status == 1 &&  menus.includes('store/store/setStoreStatus')"
													class="storeBtn">启用</button>
												<button type="primary" @click="qiAndJin(item, 1)" size="mini"
													v-if="item.status == 0 &&  menus.includes('store/store/setStoreStatus')"
													class="storeBtn">禁用</button>
												<button type="primary" @click="deleteStore(item)" size="mini"
													v-if="item.status == 1 &&  menus.includes('store/store/setStoreStatus')"
													class="storeBtn">删除</button>
												<button type="primary" @click="menPiError(item)" size="mini"
													v-if="item.store_match_status == 3 &&  menus.includes('store/store/match_error_save')"
													class="storeBtn">匹配异常处理</button>
												<button type="primary" @click="tongdian(item)" size="mini"
													v-if="menus.includes('store/diandan')"
													class="storeBtn">点单同步</button>
												<view class="" v-if="(item.store_match_status == 0 || item.store_match_status == 3 || item.store_sync_status == 2
													                                    || item.store_match_status == 4) || adminInfo.oem_id == 0">
													<button type="primary" @click="pipei(item)" size="mini"
														v-if="menus.includes('store/store/store_match')"
														class="storeBtn">提交匹配</button>
												</view>
											</view>
										</view>
									</u-collapse-item>
								</u-collapse>
							</view>
						</view>
					</view>
					<view style="width: 100%;height: 200rpx;"></view>
					<view v-if="storeList.length==0" class="np f-c-c">
						<view class="iconfont icon-queshengtu cb" style="font-size: 90rpx;"></view>
						<view class="f12 cb mt20">暂无门店</view>
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="navbar2 bt f-row">
			<view class="f-c" style="width: 168rpx;background: #FBFBFB;">门店设置</view>
			<view class="f-1 f-row bf">
				<template v-for="(v, index) in navs">
					<view class="f-1 f-y-c" @click="djTab(2)" v-if="menus.includes(v.role)">
						<view class="wh f-c f-y-c">
							<uni-icons :type="v.type" color="#FDDA34" size="22"></uni-icons>
							<view class="">{{ v.t }}</view>
						</view>
					</view>
				</template>
			</view>
		</view>
		<u-popup :show="deliveryShow" @close="close" mode="center" :round="10" :closeOnClickOverlay="false">
			<view class="popup">
				<uni-forms ref="form">
					<uni-forms-item label="配送平台" required label-width="120">
						<uni-data-checkbox v-model="ruleForm.delivery_type" :localdata="range"
							@change="checkboxChange"></uni-data-checkbox>
					</uni-forms-item>
					<uni-forms-item>
						<view
							style="display: flex;justify-content: space-between;align-items: center; margin-top: 30rpx;">
							<view class="propimg" @click="xuanzhe(1)" :class="activeName == 1 ? 'xuan' : ''"
								v-if="oem_delivery_platform['2'].status">
								<image :src="require('../../../static/zsq_logo.png')" class="image" lazy-load>
									<image :src="require('../../../static/tuijian.png')" class="secendImage" lazy-load>
									</image>
									<view class="tag">
										<u-tag text="未绑定" plain size="mini" plainFill type="info"
											v-if="ruleForm.zsq_status == 0"></u-tag>
										<u-tag text="已绑定" plain size="mini" plainFill type="warning"
											v-if="ruleForm.zsq_status == 1"></u-tag>
									</view>
								</image>
							</view>
							<view class="propimg" style="display: flex;align-items: center;"
								:class="activeName == 2 ? 'xuan' : ''" @click="xuanzhe(2)"
								v-if="oem_delivery_platform['1'].status">
								<image :src="require('../../../static/myt.png')" style="width: 100%;height: 30%;"
									lazy-load>
									<view class="tag">
										<u-tag text="未绑定" plain size="mini" plainFill type="info"
											v-if="!ruleForm.myt_token"></u-tag>
										<u-tag text="已绑定" plain size="mini" plainFill type="warning"
											v-if="ruleForm.myt_token"></u-tag>
									</view>
								</image>
							</view>
						</view>
					</uni-forms-item>
				</uni-forms>
				<view class="" v-if="activeName == 1 && oem_delivery_platform['2'].status">
					<uni-forms ref="ruleFormRef" v-if="ruleForm.zsq_status == 0">
						<uni-forms-item>
							<view class="title">选择真省钱平台补贴1%，89%的用户选择。</view>
						</uni-forms-item>
						<uni-forms-item label="门店名称">
							<u--input placeholder="请输入内容" border="surround" v-model="ruleForm.store_name"></u--input>
						</uni-forms-item>
						<uni-forms-item label="手机号">
							<u--input placeholder="请输入内容" border="surround" v-model="ruleForm.phone"></u--input>
						</uni-forms-item>
						<uni-forms-item label="所在城市">
							<u--input placeholder="请输入内容" border="surround" v-model="ruleForm.city"></u--input>
						</uni-forms-item>
						<uni-forms-item label="地址">
							<u--input placeholder="请输入内容" border="surround" v-model="ruleForm.address"></u--input>
						</uni-forms-item>
						<uni-forms-item label="经度">
							<u--input placeholder="请输入内容" border="surround" v-model="ruleForm.lng"></u--input>
						</uni-forms-item>
						<uni-forms-item label="纬度">
							<u--input placeholder="请输入内容" border="surround" v-model="ruleForm.lat"></u--input>
						</uni-forms-item>
					</uni-forms>
					<u-button type="success" text="绑定" @click="baocunzsq(ruleForm.chain_id)"
						v-if="ruleForm.zsq_status == 0"></u-button>
					<div v-if="ruleForm.zsq_status == 1"
						style="text-align: center;font-size: 30rpx;color: red;margin-bottom: 20rpx;margin-top: 40rpx;">
						您已成功绑定真省钱</div>
					<u-button type="error" text="解除绑定" @click="jiechu(ruleForm.chain_id)"
						v-if="ruleForm.zsq_status == 1"></u-button>
				</view>
				<view v-if="activeName == 2 && oem_delivery_platform['1'].status"
					style="margin: 20px; text-align: center">
					<uni-forms ref="empowerForm">
						<uni-forms-item label="授权">
							<u-button @click="clickTolicense(ruleForm.chain_id)" v-if="!ruleForm.myt_token"
								type="success">点击授权麦芽田</u-button>
							<!-- <u-button @click="getMytToken" v-if="!ruleForm.myt_token">查询授权状态</u-button> -->
							<u-button type="error" @click="jiechuaiyatian(ruleForm.chain_id)"
								v-if="ruleForm.myt_token">解除麦芽田</u-button>
						</uni-forms-item>
					</uni-forms>
				</view>
			</view>
			<view class="footer">
				<u-button @click="resetForm">取消</u-button>
				<u-button type="primary" @click="submitForm">确定</u-button>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		mapState,
	} from 'vuex'
	export default {
		data() {
			return {
				current: 0, // 预设当前项的值
				scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
				triggered: true,
				itemId: '', // 栏目右边scroll-view用于滚动的id
				storeList: [],
				newParams: {
					page: 1,
					limit: 10,
					store_name: "",
					store_sync_status: ""
				},
				deliveryShow: false,
				ruleForm: {
					contactName: '',
					contactPhone: '',
					cityName: '',
					shopAddress: '',
					shopLng: '',
					shopLat: '',
					delivery_type: 0,
				},
				oem_delivery_platform: {
					'1': {
						status: false
					},
					'2': {
						status: false
					},
					'3': {
						status: false
					}
				},
				activeName: 1,
				navs: [{
					t: '新建门店',
					type: 'plus',
					role: 'store/store/add'
				}, ],
				subColor: uni.getStorageSync('subject_color'),
				typeList: [{
						label: '全部',
						value: 0,
					},
					{
						label: '未同步',
						value: 1,
					},
					{
						label: '同步成功',
						value: 2,
					},
					{
						label: '同步失败',
						value: 3,
					},
				],
				statusList: {
					'0': {
						type: 'success',
						name: '正常',
					},
					'1': {
						type: 'error',
						name: '禁用',
					},
				},
				store_match_statusList: {
					'0': {
						type: 'success',
						name: '未匹配',
					},
					'1': {
						type: 'info',
						name: '已提交',
					},
					'2': {
						type: 'success',
						name: '成功',
					},
					'3': {
						type: 'error',
						name: '失败',
					},
					'4': {
						type: 'info',
						name: 'OEM批量匹配中',
					},
				},
				store_sync_statusList: {
					'0': {
						type: 'info',
						name: '未同步',
					},
					'1': {
						type: 'success',
						name: '同步成功',
					},
					'2': {
						type: 'error',
						name: '同步失败',
					},
				},
				place_statusList: {
					'1': {
						type: 'success',
						name: '接单',
					},
					'2': {
						type: 'error',
						name: '不接单',
					}
				},
				delivery_typeList: {
					'0': {
						type: 'success',
						name: '未绑定',
					},
					'1': {
						type: 'success',
						name: '麦芽田',
					},
					'2': {
						type: 'info ',
						name: '船到',
					},
					'3': {
						type: 'error',
						name: '真省钱',
					},
				},
				audi_statusList: {
					'0': {
						type: 'info',
						name: '待审核',
					},
					'1': {
						type: 'success',
						name: '审核通过',
					},
					'2': {
						type: 'error',
						name: '审核拒绝',
					},
				},
				hasLoadedData: false,
				adminInfo: uni.getStorageSync('adminInfo'),
				is_audi: 0,
				loading: false,
				range: [{
						text: "真省钱",
						value: 3
					},
					{
						text: "麦芽田",
						value: 1
					}
				],
			}
		},
		computed: {
			...mapState({
				menus: state => state.menus,
			}),
		},
		methods: {
			getInfo() {
				this.beg.request({
					url: '/admin/store.Store/getStoreInfo',
					method: 'post',
					data: {
						id: this.ruleForm.id
					}
				}).then(res => {
					if (res.code == 1) {
						this.ruleForm = {
							...this.ruleForm.value,
							...res.data
						}
						if (this.ruleForm.zsq_status == 0) {
							this.getzsq()
							if (this.ruleForm.delivery_type == 3) {
								this.ruleForm.delivery_type = 0
							}
						}
					}
				})
			},
			// 获取门店信息
			getStoreIndex() {
				uni.showLoading()
				this.beg.request({
					url: "/admin/store.Store/index",
					method: 'POST',
					data: this.newParams,
				}).then(res => {
					if (res.code == 1) {
						uni.hideLoading()
						res.data.data.forEach((v) => {
							if (v.bus_img != null && v.bus_img != '') {
								v.bus_img = JSON.parse(v.bus_img)
							} else {
								v.bus_img = []
							}
							if (v.logo_img != null && v.logo_img != '') {
								v.logo_img = JSON.parse(v.logo_img)
							} else {
								v.logo_img = []
							}
							if (v.open_time != null && v.open_time != '') {
								v.open_time = JSON.parse(v.open_time)

							} else {
								v.open_time = [
									[],
									[]
								]
							}
							if (v.store_img != null && v.store_img != '') {
								v.store_img = JSON.parse(v.store_img)
							} else {
								v.store_img = []
							}
							if (v.open_date != null && v.open_date != '') {
								v.open_date = JSON.parse(v.open_date).map(item => parseInt(item, 10))
							} else {
								v.open_date = []
							}
							if (v.qualifications != null && v.qualifications != '') {
								v.qualifications = JSON.parse(v.qualifications)
							} else {
								v.qualifications = []
							}
							if (v.business_license != null && v.business_license != '') {
								v.business_license = JSON.parse(v.business_license)
							} else {
								v.business_license = []
							}
							if (v.authorization != null && v.authorization != '') {
								v.authorization = JSON.parse(v.authorization)
							} else {
								v.authorization = []
							}

							if (v.distance_price != null && v.distance_price != '') {
								v.distance_price = JSON.parse(v.distance_price)
							}
							if (v.dy_status == 2) {
								v.dy_status_name = false;
							} else {
								v.dy_status_name = true;
							}
						})
						let newData = res.data.data
						if (!this.hasLoadedData) {
							this.storeList = newData;
							this.hasLoadedData = true;
						} else {
							this.storeList = this.storeList.concat(newData);
						}
					}

				})
			},
			// 点击左边的栏目切换
			async swichMenu(index) {
				if (index == 0) {
					this.newParams.store_sync_status = ''
				} else {
					this.newParams.store_sync_status = index - 1;
				}
				this.current = index;
				this.newParams.page = 1;
				this.hasLoadedData = false;
				this.storeList = []
				this.getStoreIndex()
			},
			editStore(item, type) {
				const encodedItem = encodeURIComponent(JSON.stringify(item));
				const url = `/pages/home/store/store?item=${encodedItem}&type=${type}`;
				uni.navigateTo({
					url: url
				});
			},
			peishong(item) {
				this.deliveryShow = true
				this.beg.request({
					url: '/admin/oem.Oem/getOmeInfo',
					method: 'get',
					data: {
						id: item.oem_id
					}
				}).then(res => {
					if (res.data.oem_delivery_platform != null) {
						let delivery_platform = JSON.parse(res.data.oem_delivery_platform);
						delivery_platform.forEach((v) => {
							this.oem_delivery_platform[v].status = true;
						})
					}
					this.ruleForm = {
						...this.ruleForm,
						...item
					}
					if (item.delivery_type == 1) {
						this.activeName = 2
					} else if (item.delivery_type == 3) {
						this.activeName = 1
					} else {
						this.activeName = 1
					}
					if (item.zsq_status == 0) {
						this.getzsq(item)
					}
				})
			},
			peishongRule(item, type) {
				const encodedItem = encodeURIComponent(JSON.stringify(item));
				const url = `/pages/home/store/store?item=${encodedItem}&type=${type}`;
				uni.navigateTo({
					url: url
				});
			},
			xuanzhe(i) {
				this.activeName = i
			},
			baocunzsq(chain_id) {
				this.beg.request({
					url: '/api/delivery_app.ZhenShengqian/create_store',
					method: 'post',
					data: {
						store_id: chain_id
					}
				}).then(res => {
					if (res.code == 1) {
						this.getInfo()
						uni.$u.toast('操作成功')
					} else {
						uni.$u.toast('操作失败')
					}
				})
			},
			jiechu(chain_id) {
				this.beg.request({
					url: '/api/delivery_app.ZhenShengqian/del_zsq',
					method: 'post',
					data: {
						store_id: chain_id
					}
				}).then(res => {
					if (res.code == 1) {
						this.getInfo()
						uni.$u.toast('操作成功')
					} else {
						uni.$u.toast('操作失败')
					}
				})
			},
			getzsq(item) {
				this.beg.request({
					url: '/api/delivery_app.ZhenShengqian/sms_authorize',
					method: 'post',
					data: {
						store_id: item.id
					}
				}).then(res => {
					if (res.code == 1) {
						this.ruleForm = {
							...this.ruleForm,
							...res.data
						}
					}
				})
			},
			clickTolicense() {
				if (this.ruleForm.myt_token) {
					uni.$u.toast('已授权')
					return
				}
				this.beg.request({
					url: '/index.php/api/delivery_app.Maiyatian/get_maiyatian_code',
					method: 'post',
					data: {
						shop_id: this.ruleForm.id
					}
				}).then(res => {
					if (res.code == 1) {
						let content = res.data
						uni.showModal({
							title: '提示',
							content: '点击复制链接到浏览器打开',
							confirmText: '复制链接',
							success: function(res) {
								if (res.confirm) {
									uni.setClipboardData({
										data: content,
										success: () => {
											uni.showToast({
												title: '已复制到剪贴板',
												icon: 'none',
												duration: 2000
											});
										}
									});
								}
							}
						});
					}
				})
			},
			jiechuaiyatian() {
				this.beg.request({
					url: '/index.php/api/delivery_app.Maiyatian/del_myt',
					method: 'post',
					data: {
						id: this.ruleForm.id
					}
				}).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.getInfo()
						uni.$u.toast('操作成功')
					} else {
						uni.$u.toast('操作失败')
					}
				})
			},
			checkboxChange(e) {
				if (e.detail.value == 3) {
					this.beg.request({
						url: '/admin/store.Store/getStoreInfo',
						method: 'post',
						data: {
							id: this.ruleForm.id
						}
					}).then(res => {
						if (res.code == 1) {
							switch (e.detail.value) {
								case 1:
									if (res.data.zsq_status != 1) {
										this.ruleForm.delivery_type = 0
										uni.$u.toast('暂未绑定成功')
									}
									break
							}
						}
					})
				}
			},
			close() {
				this.deliveryShow = false
			},
			submitForm() {
				if (this.ruleForm.delivery_type == 0) {
					uni.$u.toast('请选择配送平台')
					return
				}
				this.beg.request({
					url: '/admin/store.Store/edit_delivery_type',
					method: 'post',
					data: {
						store_id: this.ruleForm.id,
						delivery_type: this.ruleForm.delivery_type
					}
				}).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.deliveryShow = false
						this.hasLoadedData = false
						this.getStoreIndex()
						uni.$u.toast(res.msg)
					} else {
						uni.$u.toast('操作失败')
					}
				})
			},
			resetForm() {
				this.ruleForm.value = {
					contactName: '',
					contactPhone: '',
					cityName: '',
					shopAddress: '',
					shopLng: '',
					shopLat: '',
					delivery_type: 0,
				}
				this.deliveryShow = false
			},
			// 进件
			jinjian(item) {
				this.beg.request({
					url: '/index.php/admin/store.Store/app_add_sub_merchant',
					method: 'post',
					data: {
						store_id: item.id
					}
				}).then(res => {
					if (res.code == 1) {
						let content = res.data
						uni.showModal({
							title: '提示',
							content: '点击复制链接到浏览器打开',
							confirmText: '复制链接',
							success: function(res) {
								if (res.confirm) {
									uni.setClipboardData({
										data: content,
										success: () => {
											uni.showToast({
												title: '已复制到剪贴板',
												icon: 'none',
												duration: 2000
											});
										}
									});
								}
							}
						});
						// let str = res.data
						// uni.navigateTo({
						// 	url: `/pages/home/webview/webview?url=${str}`
						// })
					}
				})
			},
			djTab(type) {
				uni.navigateTo({
					url: `/pages/home/store/store?type=${type}`
				})
			},
			tong(val) {
				//判断配送规则是否填写
				if (val.open_time[0].length == 0) {
					uni.$u.toast('请设置配送规则')
					return;
				}
				this.beg.request({
						url: '/admin/store.Store/dy_store_sync',
						method: 'POST',
						data: {
							id: val.id,
						}
					}).then((res) => {
						if (res.code == 1) {
							uni.$u.toast(res.msg)
							setTimeout(res => {
								this.hasLoadedData = false;
								this.newParams.page = 1
								this.getStoreIndex()
							}, 800)
							uni.$u.toast(res.msg)
						}
					})
					.catch(() => {})
			},
			scrolltolower() {
				this.newParams.page++
				this.getStoreIndex()
			},
			toSearch() {
				this.hasLoadedData = false;
				this.getStoreIndex()
			},
			getOemInfoObj() {
				this.beg.request({
					url: '/admin/oem.Oem/getOmeInfo',
					data: {
						id: this.adminInfo.oem_id,
					}
				}).then(res => {
					if (res.code == 1) {
						this.is_audi = res.data.is_audi
					}
				})
			},
			tipsShowTap(value) {
				uni.showModal({
					title: '审核失败',
					showCancel: false,
					content: value
				})
			},
			chaPi(val) {
				if (val.store_match_status == 0) {
					return
				}
				this.beg.request({
						url: '/admin/store.Store/store_query_task',
						method: 'post',
						data: {
							id: val.id,
						}
					})
					.then((res) => {
						if (res.code == 1) {
							uni.$u.toast(res.msg)
							setTimeout(res => {
								this.hasLoadedData = false;
								this.newParams.page = 1
								this.getStoreIndex()
							}, 800)
						} else {
							uni.$u.toast(res.msg)
						}
					})
					.catch(() => {})
			},
			qiAndJin(val, status) {
				let name = ''
				if (status == 0) {
					name = '启用'
				} else if (status == 1) {
					name = '禁用'
				}
				uni.showModal({
					title: '提示',
					content: `确定${name}该门店？`,
					success: (res) => {
						if (res.confirm) {
							this.beg.request({
									url: '/admin/store.Store/setStoreStatus',
									method: 'post',
									data: {
										id: val.id,
										status: status,
									}
								}).then((res) => {
									if (res.code == 1) {
										this.hasLoadedData = false;
										this.newParams.page = 1
										this.getStoreIndex()
										uni.$u.toast(res.msg)
									} else {
										uni.$u.toast('操作失败')
									}
								})
								.catch(() => {})
						}
					}
				})
			},
			deleteStore(val) {
				uni.showModal({
					title: '提示',
					content: `确定删除该门店(${val.store_name})？`,
					success: (res) => {
						if (res.confirm) {
							this.beg.request({
								url: '/admin/store.Store/delete',
								method: 'post',
								data: {
									id: val.id
								}
							}).then(res => {
								if (res.code == 1) {
									uni.$u.toast(res.msg)
									setTimeout(res => {
										this.hasLoadedData = false;
										this.newParams.page = 1
										this.getStoreIndex()
									}, 800)
								} else {
									uni.$u.toast('操作失败')
								}
							})
						}
					}
				})
			},
			menPiError(val) {
				this.beg.request({
						url: '/admin/store.Store/match_error_save',
						method: 'post',
						data: {
							id: val.id,
							status: 2
						}
					})
					.then((res) => {
						uni.$u.toast(res.msg)
						setTimeout(res => {
							this.hasLoadedData = false;
							this.newParams.page = 1
							this.getStoreIndex()
						}, 800)
					})
					.catch((err) => {})
			},
			tongdian(val) {
				this.beg.request({
						url: '/admin/store.Store/sync_place_info',
						method: 'post',
						data: {
							id: val.id,
						}
					})
					.then((res) => {
						if (res.code == 1) {
							uni.$u.toast(res.msg)
							setTimeout(res => {
								this.hasLoadedData = false;
								this.newParams.page = 1
								this.getStoreIndex()
							}, 800)
						} else {
							uni.$u.toast(res.msg)
						}
					})
					.catch(() => {})
			},
			switchBtn(val) {
				let dy_status = 1;
				if (val.dy_status == 1) {
					dy_status = 2;
				} else {
					dy_status = 1;
				}
				this.beg.request({
						url: '/admin/store.Store/setOpStatus',
						method: 'post',
						data: {
							id: val.id,
							dy_status: dy_status
						}
					})
					.then((res) => {
						if (res.code == 1) {
							uni.$u.toast(res.msg)
							setTimeout(res => {
								this.hasLoadedData = false;
								this.newParams.page = 1
								this.getStoreIndex()
							}, 800)
						} else {

							uni.$u.toast(res.msg)
						}
					})
					.catch(() => {})
			},
			// matchShowTap(value) {
			// 	uni.showModal({
			// 		title: '审核失败',
			// 		showCancel: false,
			// 		content: value
			// 	})
			// },
			pipei(val) {
				this.beg.request({
						url: '/admin/store.Store/store_match',
						method: 'post',
						data: {
							id: val.id,
						}
					})
					.then((res) => {
						if (res.code == 1) {
							uni.$u.toast(res.msg)
							setTimeout(res => {
								this.hasLoadedData = false;
								this.newParams.page = 1
								this.getStoreIndex()
							}, 800)
						} else {
							uni.$u.toast(res.msg)
						}
					})
					.catch(() => {})
			},
		},
		onShow() {
			this.hasLoadedData = false
			this.newParams.page = 1
			this.getOemInfoObj()
			this.getStoreIndex()
		},
	}
</script>
<style>
	page {
		background-color: #fff;
	}
</style>
<style lang="scss" scoped>
	$lee-tab-item-active: #c6ebff;

	.lee-wrap {
		height: 100%;
	}

	.container {
		/* #ifdef H5 */
		height: calc(100vh - var(--window-top));
		/* #endif */
		display: flex;
		flex: 1;
		height: 100%;
	}

	.lee-tab-view {
		width: 200rpx;
		height: 100%;
	}

	.lee-tab-item {
		height: 110rpx;
		background: #f6f6f6;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 24rpx;
		color: #444;
		font-weight: 400;
		line-height: 1;
	}

	.lee-tab-item-active {
		position: relative;
		font-size: 24rpx;
		font-weight: 500;
		background: #fff;
	}

	.page-view {
		background-color: #fff;
		padding: 16rpx;
	}

	.class-item {
		padding: 5rpx 5rpx;
		border-radius: 8rpx;
	}

	.navbar2 {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 100rpx;
		background: #fff;
		box-shadow: 0 0rpx 8rpx 4rpx rgba(0, 0, 0, 0.05);
	}

	.status {
		display: flex;
		justify-content: start;
		align-items: center;
	}

	.content-text {
		margin-top: 10rpx;
	}

	.setting {
		// display: flex;
		// flex-wrap: wrap;
		// justify-content: space-between;
		// align-items: center;
	}

	.popup {
		width: 680rpx;
		padding: 30rpx;

		.propimg {
			width: 250rpx;
			height: 250rpx;
			box-shadow: 0px 1px 7px 0px #888888;
			position: relative;

			.image {
				width: 100%;
				height: 100%;
			}

			.secendImage {
				width: 70rpx;
				height: 70rpx;
				position: absolute;
				left: 0;
				top: 0;
			}

			.tag {
				position: absolute;
				right: 0;
				top: 0;
			}
		}

		.xuan {
			border: 2px solid #036ee9;
		}
	}

	.footer {
		display: flex;
		justify-content: space-between;
		align-items: center;

		::v-deep .u-button--square {
			width: 30%;
		}
	}

	::v-deep .uni-forms-item {
		align-items: center;
		margin-bottom: 10rpx;
	}

	.storeBtn {
		background-color: #fdda34;
		color: #000;
		font-weight: 600;
		margin-top: 10rpx;
		margin-left: 20rpx;
	}
</style>